package com.bai.statistics.controller;


import com.bai.statistics.client.UcenterClient;
import com.bai.statistics.service.DailyService;
import com.bai.utils.R;
import com.sun.javafx.collections.MappingChange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Objects;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author bai
 * @since 2023-08-21
 */
@RestController
@RequestMapping("/statistics/daily")
@CrossOrigin
public class DailyController {

    @Autowired
    private DailyService dailyService;

    //TODO:统计某一天注册人数,生成统计数据
    @PostMapping("registerCount/{day}")
    public R registerCount(@PathVariable String day){
       dailyService.registerCount(day);
       return R.ok();
    }

    //TODO:图表显示，返回两部分数据，日期json数据，数量json数据
    @GetMapping("showData/{type}/{begin}/{end}")
    public R showData(@PathVariable String type,
                      @PathVariable String begin,
                      @PathVariable String end){
        Map<String, Object> map= dailyService.getShowData(type,begin,end);
        return R.ok().data("map",map);
    }
}

